import { hsqjInputJson, gdzczjJson } from '../data/hsqj-json.js';
import { saasTosj, fillInputDone } from '../../common.js';

function fillHspj(resData, sheet) {
  try {

    let data = saasTosj(resData, hsqjInputJson, gdzczjJson)
    // data = {...data, ...gdzczj}
    // let contents = $('#reportBody > iframe').contents();
    let currentBtn = $('#editList .active').attr('data-bbid');
    let contents = $(`#reportBody > iframe[id=iframe_${currentBtn}]`).contents();
    Object.keys(data).forEach((item) => {

      let input = contents.find(`#${item}`);
      input.focus();
      // input.val(parseFloat('1220').toFixed(2));
      input.val(parseFloat(data[item]).toFixed(2));
      input.blur();
    });

    fillInputDone({
      tax: 'hsqj',
      success: true,
      message: "汇算清缴-填报成功",
    })
  } catch (e) {
    console.log(e);
    fillInputDone({
      tax: 'hsqj',
      success: false,
      message: "汇算清缴-填报失败，请联系技术人员",
    })
  }

}

export { fillHspj }